#include <climits>
#include <string>
using namespace std;
#include <vector>

class Solution
{
public:
    vector<int> missingTwo(vector<int>& nums)
    {
        int n = nums.size();
        int ret = 0;
        for(auto x : nums)
            ret ^= x;
        for(int i=1; i<=n+2; i++)
            ret ^= i;

        int dif = (ret == INT_MIN ? ret : ret & -ret);
        int num1 = 0, num2 = 0;
        for(int i=1; i<=n+2; i++)
        {
            if(i & dif)
                num1 ^= i;
            else
                num2 ^= i;
        }
        for(auto x : nums)
        {
            if(x & dif)
                num1 ^= x;
            else
                num2 ^= x;
        }
        return {num1, num2};
    }
};